********************************************************************************
*                                                                              *
*           WHY DO PEOPLE USE INFORMAL JUSTICE? REPLICATION (JEPS)             *
*                                                                              *
********************************************************************************

  

* define data and results paths (fill in with your own URL)
global PathData = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/1_Data/"
global PathTab = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/4_Writing/z_tables/to_edit/"

* upload the main data file (with original survey)
use "${PathData}fata_data.dta", clear


* create reliance on informal justice measure
gen informal_justice = 1 if tribal_eld==1 | relig_leader==1
replace informal_justice = 0  if tribal_eld==0 & relig_leader==0

* create resourcelessness measure (by first dividing month household income by family size, and second taking a log of it and reversing the variable)
gen mont_inc_cap = mont_inc/fam_size
gen lnmont_incm = ln(mont_inc_cap+1)
gen Resourcelessness = lnmont_incm*(-1)

* create inefficiency measure
gen Inefficiency = 0 if justice==1 & just_govt==2
replace Inefficiency = 0 if justice==1 & just_army==3
replace Inefficiency = 1 if just_govt!=2 | just_army!=3

* create conventions measure
bysort vill_code: egen Conventions=mean(informal_justice)


* recode control (by reversing the scale)
gen religiosity = religious_prac*(-1)


* standardize and label
zval Resourcelessness Inefficiency Conventions informal_justice
label variable z_Resourcelessness "Resourcelessness"
label variable z_Inefficiency "Inefficiency"
label variable z_Conventions "Conventions"


* Table A12
eststo clear
eststo Informal_Justice: reghdfe z_informal z_Resourcelessness z_Inefficiency z_Conventions religiosity i.religion i.education age i.sex fam_size i.marital_stat, abs(agency_code)
estadd local controls = "Yes"
esttab Informal_Justice using "${PathTab}TableA12.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(controls r2 N, labels("Controls" "R-squared" "N")) label nodepvar mtitles title("Determinants of Informal Justice (Pakistan Data)") replace nonotes postfoot(" ")


